import os
import logging
import logging.config
from view.ctrl_mainWindow import mainControl
from PyQt5 import QtCore, QtGui, QtWidgets

import sys


def main():
    app = QtWidgets.QApplication(sys.argv)
    window = mainControl()
    window.show()
    sys.exit(app.exec_())


def mkdir():
    project_path = os.path.abspath(os.path.dirname(__file__))
    # Windows
    if project_path.find('\\') != -1: separator = '\\'
    # Mac、Linux、Unix
    if project_path.find('/') != -1: separator = '/'

    log_path = project_path + separator + 'log'
    out_path = project_path + separator + 'out'

    if not os.path.exists(log_path):
        os.makedirs(log_path)
    if not os.path.exists(out_path):
        os.makedirs(out_path)


if __name__ == '__main__':
    # 初始化文件夹
    mkdir()
    # 初始化日志
    logging.config.fileConfig('conf/logging.conf')
    logger = logging.getLogger('applog')
    logger.debug("app is run")
    main()
